<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../include/base.jsp"%>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title>凯盛项目管理系统</title>
	<meta charset="UTF-8">
	<title>欢迎使用CRM管理系统</title>
    <link rel="stylesheet" href="${basePath }/css/bootstrap.min.css" type="text/css" />
    <link rel="stylesheet" href="${basePath }/css/style.css" type="text/css" />
    <script type="text/javascript" src="${basePath }/js/jquery.min.js"></script>
    <script type="text/javascript" src="${basePath }/js/bootstrap.min.js"></script>
</head>
<body>
    <div class="navbar">
        <div class="navbar-inner">
            <div class="container">
                <a href="${basePath }/message" class="brand">凯盛CRM管理系统</a>
                <div class="nav-collapse">
                    <ul class="nav">
                        <li><a href="#">最新动态</a></li>
                        <li><a href="${basePath }/contacts/list">联系人</a></li>
                        <li><a href="${basePath }/task/list">日程安排</a></li>
                        <li><a href="${basePath }/deal/list">业务机会</a></li>
                    </ul>
                    <ul class="nav pull-right">
                        <li><a href="#">${user.username }</a></li>
                        <li class="divider-vertical"></li>
                        <li class="active"><a href="#">账号设置</a></li>
                        <li><a href="${basePath }/user/loginout">退出</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <div id="content" class="container">
       	<div class="span3" style="float:left;">
			<div class="wall">
				<ul class="nav nav-list">
					<li class="nav-header">个人资料</li>
					<li class="divider"></li>
					<li >
						<a href="${basePath }/user/info">
							<i class="icon-user"></i>个人资料
						</a>
					</li>
					<li class="active">
						<a href="#">
							<i class="icon-white icon-qrcode"></i>修改密码
						</a>
					</li>
				</ul>
			</div>
		</div>
		<div class="span9" style="float:right;">
            <form class="form-horizontal" action="${basePath }/user/editpwd" method="post" id = "myform">
                 <fieldset>  
                     <legend>修改登录密码</legend>
                 	 	<c:choose>
							<c:when test="${param.code == '1' }">
								<div class="alert alert-error">
									<button class="close" data-dismiss="alert">×</button>
									<strong>修改成功</strong>
								</div>
							</c:when>
							<c:when test="${param.code == '2' }">
								<div class="alert alert-error">
									<button class="close" data-dismiss="alert">×</button>
									<strong>密码错误或两次密码不一致，修改失败</strong>
								</div>
							</c:when>
						</c:choose>   
					 <div class="control-group" id="oldpwddiv">
                         <label class="control-label" for="oldpwd">请输入旧密码</label>
                         <div class="controls">
                             <input type="password" class="input-xlarge" id="oldpwd" name="oldpwd">
							 <span class="help-inline" id="span1"></span>
                         </div>
                     </div>
					<div class="control-group" id="newpwddiv">
                         <label class="control-label" for="newpwd">请输入新密码</label>
                         <div class="controls">
                             <input type="password" class="input-xlarge" id="newpwd" name="newpwd">
					<span class="help-inline" id="span2"></span>
                         </div>
                     </div>
					<div class="control-group" id="confirmpwddiv">
                         <label class="control-label" for="confirmpwd">请确认新密码</label>
                         <div class="controls">
                             <input type="password" class="input-xlarge" id="confirmpwd" name="confirmpwd">
					<span class="help-inline" id="span3"></span>
                         </div>
                     </div>
                     <div class="form-actions">
                         <button class="btn btn-primary" type="button" id="btn">修改</button>
                         <a href="main" class="btn">返回</a>
                     </div>
                 </fieldset>
             </form>
        </div>
    </div>
    <script type="text/javascript">
		$(document).ready(function(){
			
			$("#oldpwd").focus(function(){
				$("#span1").html("");
				$("#oldpwddiv").removeClass("error");
			});
			$("#oldpwd").blur(function(){
				var oldpwd = $(this).val();
				if (oldpwd == "") {
					$("#span1").html("旧密码不能为空");
					$("#oldpwddiv").addClass("error");
				}
			});
			$("#newpwd").focus(function(){
				$("#span2").html("");
				$("#span3").html("");
				$("#newpwddiv").removeClass("error");
				$("#confirmpwddiv").removeClass("error");
				$("#confirmpwd").val("");
			});
			$("#newpwd").blur(function(){
				var pwd = $(this).val();
				if (pwd == "") {
					$("#span2").html("请输入新密码");
					$("#newpwddiv").addClass("error");
				}
			});	
			$("#confirmpwd").focus(function(){
				$("#span3").html("");
				$("#confirmpwddiv").removeClass("error");
			});
			$("#confirmpwd").blur(function(){
				var confirmpwd = $(this).val();
				var newpwd = $("#newpwd").val();
				if (confirmpwd == "") {
					$("#span3").html("请再次输入新密码");
					$("#confirmpwddiv").addClass("error");
				}
				if (confirmpwd != newpwd) {
					$("#span2").html("两次密码输入不一致");
					$("#newpwddiv").addClass("error");
				}
			});				
  			$("#btn").click(function(){
  				var oldpwd = $("#oldpwd").val();
  				var newpwd = $("#newpwd").val();
				var confirmpwd = $("#confirmpwd").val();
  				if (oldpwd == "") {
					$("#span1").html("旧密码不能为空");
					$("#oldpwddiv").addClass("error");
				}
  				if (newpwd == "") {
					$("#span2").html("请输入新密码");
					$("#newpwddiv").addClass("error");
				}
				if (confirmpwd == "") {
					$("#span3").html("请再次输入新密码");
					$("#confirmpwddiv").addClass("error");
				}
				if (confirmpwd != newpwd) {
					$("#span2").html("两次密码输入不一致");
					$("#newpwddiv").addClass("error");
				}
  				if (oldpwd != "" && newpwd != "" && confirmpwd != "" && confirmpwd == newpwd) {
					$("#myform").submit();
				}
  			});
  		});
	</script>
</body>
</html>
